//
//  ViewController.swift
//  centerDemo
//
//  Created by 李煜 on 2024/1/10.
//

import UIKit

class ViewController: UIViewController {
    let blue: UIView = .init(frame: .init(x: 0, y: 100, width: 300, height: 200))
    let pink: UIView = UIView()
    lazy var superView2 = {
        let v = UIView()

        view.addSubview(v)
        v.backgroundColor = .systemPurple

        return v
    }()
    override func viewDidLoad() {
        super.viewDidLoad()
        blue.backgroundColor = .systemBlue
        pink.backgroundColor = .systemPink

        pink.bounds = .init(x: 0, y: 150, width: 100, height: 100)
        view.addSubview(blue)
        print(blue.center)
        print(pink.center)
        blue.addSubview(pink)
        //        要使此句有效果 中心重合,必须父视图原点origin坐标是(0,0)
        pink.center = blue.center
        blue.frame.origin = .init(x: 0, y: 0)
    }


}

